/*
 * Copyright 2009 Eat Local Food, LLC
 * Copyright (c) 2007 osCommerce (this file was written after
 * code review of osCommerce).
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.elf.gwt.common.client.subcomponent;

import com.elf.gwt.common.client.CommonComponentController;
import com.elf.gwt.common.client.utils.CommonUtils;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.FormPanel;
import com.google.gwt.user.client.ui.Hidden;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 *  Subcomponent for switching to SSL when going to checkout
 */
public class SwitchToSSLSubComponent extends FormPanel
{

	/**
	 * Constructor
	 */
	public SwitchToSSLSubComponent(CommonComponentController controller, String token, String cartContents)
	{
		super("_top");
		try {
			String url = CommonUtils.getSslUrl();
			this.setAction(url);
			this.setMethod(FormPanel.METHOD_POST);

			VerticalPanel verticalPanel = new VerticalPanel();
			add(verticalPanel);
			verticalPanel.add(new Hidden("token", token));
			verticalPanel.add(new Hidden("action", "SwitchToSSL"));
			verticalPanel.add(new Hidden("cart", cartContents));

			if(!GWT.isScript()) CommonUtils.testSSL = false;
		}
		catch (Exception e) {GWT.log("SwitchToSSLSubComponent", e);}
	}
}
